/* eslint-disable react/sort-comp */
/* eslint-disable react/no-did-mount-set-state */
/* eslint-disable react/jsx-no-bind */
import { h, Component, Fragment } from 'preact';
import classNames from 'classnames';
import Menu from './Menu';

export default class BaseMenu extends Component {

	static defaultProps = {
		onReady: _ => _
	}

	state = {
		hidden: true
	}

	componentDidMount() {
		const { onReady } = this.props;
		onReady(this);
		// document.addEventListener('click',() => {
		// 	this.setState({ hidden: true });
		// });
	}

	toggle = _ => {
		this.setState((state) => ({ ...state,hidden: !state.hidden }));
	}
 
	render(props, state) {
		return (
			<Fragment>
				<div className={classNames({ hidden: state.hidden})}>
					<Menu isMobile onMenuClick={_ => this.toggle()} style={{zIndex:1066}}/>
					<div onClick={_ => this.toggle()} className={classNames('modal-backdrop fade show modal-global')} tabindex="-1" role="dialog" style={{display:'block',zIndex:1055}} />
				</div> 
			</Fragment>
		);
	}
}